require(["../scripts/conf/config.js"], function(){
	require(["jquery","swiper"], function($,Swiper){
        $(function(){
            var myId;
            var myLocation = window.location.href;
            console.log(myLocation);
            var re = /[^=]+=/;
            myId = myLocation.replace(re,'');

            let detailImgIcon = document.getElementsByClassName('detail-img-icon')[0];
            let projectName = document.getElementsByClassName('project-name')[0];
            let productInfoName = document.getElementsByClassName('product-info-name')[0];
            let productInfoTime = document.getElementsByClassName('product-info-time')[0];
            let vueneName = document.getElementsByClassName('vuene-name')[0];
            let addressName = document.getElementsByClassName('address-name')[0];
            let screens = document.getElementsByClassName('screens')[0];
            let tickets = document.getElementsByClassName('tickets')[0];
            let wantContent = document.getElementsByClassName('want-content')[0];
            let myInfoTitle = document.getElementsByClassName('my-info-title');
            let myInfoBody = document.getElementsByClassName('my-info-body');


            mainFunction();
            
            function mainFunction(){
                $.ajax({
					type : 'GET',
					url : `/api/ticket/project/get?version=134&id=${myId}`,
					success(data){
                        console.log(data);
                        detailImgIcon.style.backgroundImage = `url(http:${data.data.cover})`;
                        projectName.innerHTML = data.data.name;
                        productInfoName.innerHTML = data.data.name;
                        productInfoTime.innerHTML = data.data.project_label;
                        vueneName.innerHTML = data.data.venue_info.name;
                        addressName.innerHTML = data.data.venue_info.address_detail;
                        if(data.data.screen_list){
                            for(let i=0;i<data.data.screen_list.length;i++){
                                var selectableOption = document.createElement('div');
                                selectableOption.className = 'selectable-option';
                                selectableOption.innerHTML = data.data.screen_list[i].name;
                                screens.appendChild(selectableOption);
                            }
                            for(let j=0;j<data.data.screen_list[0].ticket_list.length;j++){
                                var selectableOption = document.createElement('div');
                                selectableOption.className = 'selectable-option' ;
                                selectableOption.innerHTML = `￥${data.data.screen_list[0].ticket_list[j].price/100}（${data.data.screen_list[0].ticket_list[j].desc}）`;
                                tickets.appendChild(selectableOption);
                            }
                        }
                        wantContent.innerHTML = `<p>${data.data.wish_info.count}</p>`;
                        
                        for(let k=0;k<myInfoTitle.length;k++){
                            myInfoTitle[k].innerHTML = data.data.performance_desc.list[0].details[k].title;
                        }
                        for(let l=0;l<myInfoBody.length;l++){
                            myInfoBody[l].innerHTML = data.data.performance_desc.list[0].details[l].content;
                        }
                    }
                })
            }


        })
    })
})